
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module newlib.SmapHttp</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="newlib.html"><font color="#ffffff">newlib</font></a>.SmapHttp</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/sdawson/svn/code/smap/newlib/SmapHttp.py">/home/sdawson/svn/code/smap/newlib/SmapHttp.py</a></font></td></tr></table>
    <p><tt>Functions&nbsp;and&nbsp;classes&nbsp;for&nbsp;running&nbsp;an&nbsp;HTTP&nbsp;server&nbsp;providing&nbsp;sMAP<br>
resources.<br>
&nbsp;<br>
To&nbsp;create&nbsp;the&nbsp;simplest&nbsp;SMAP&nbsp;service,&nbsp;first&nbsp;instantiate&nbsp;a&nbsp;SmapInstance<br>
object.&nbsp;&nbsp;Then&nbsp;start&nbsp;a&nbsp;server&nbsp;using&nbsp;this&nbsp;module.&nbsp;&nbsp;See&nbsp;the&nbsp;SmapInstance<br>
documentation&nbsp;for&nbsp;more&nbsp;information&nbsp;on&nbsp;adding&nbsp;data.<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;data&nbsp;=&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'0'&nbsp;:&nbsp;{'0'&nbsp;:&nbsp;SmapPoint.SmapPoint(SmapPoint.Formatting(unit='kW',multiplier=None,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;divisor=None,type='electric',<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ctype='sensor'),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SmapPoint.Parameter(interval=1,&nbsp;time='second'))&nbsp;}&nbsp;}<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;inst&nbsp;=&nbsp;SmapInstance.SmapInstance(data)<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;SmapHttp.<a href="#-start_server">start_server</a>(inst,&nbsp;port=8080)<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;By&nbsp;default,&nbsp;this&nbsp;will&nbsp;block&nbsp;and&nbsp;run&nbsp;in&nbsp;the&nbsp;foreground.&nbsp;&nbsp;If&nbsp;you<br>
&nbsp;&nbsp;&nbsp;&nbsp;want&nbsp;it&nbsp;to&nbsp;spawn&nbsp;a&nbsp;daemon&nbsp;thread,&nbsp;you&nbsp;can&nbsp;use&nbsp;the&nbsp;background<br>
&nbsp;&nbsp;&nbsp;&nbsp;keyword&nbsp;argument:<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;SmapHttp.start_server.SmapInstance(data,&nbsp;background=True,&nbsp;port=8080)</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="newlib.Reporting.html">newlib.Reporting</a><br>
<a href="newlib.SmapInstance.html">newlib.SmapInstance</a><br>
<a href="json.html">json</a><br>
</td><td width="25%" valign=top><a href="logging.html">logging</a><br>
<a href="re.html">re</a><br>
<a href="newlib.smaplog.html">newlib.smaplog</a><br>
</td><td width="25%" valign=top><a href="thread.html">thread</a><br>
<a href="threading.html">threading</a><br>
<a href="urlparse.html">urlparse</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="BaseHTTPServer.html#BaseHTTPRequestHandler">BaseHTTPServer.BaseHTTPRequestHandler</a>(<a href="SocketServer.html#StreamRequestHandler">SocketServer.StreamRequestHandler</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="newlib.SmapHttp.html#SmapHandler">SmapHandler</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="BaseHTTPServer.html#HTTPServer">BaseHTTPServer.HTTPServer</a>(<a href="SocketServer.html#TCPServer">SocketServer.TCPServer</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="newlib.SmapHttp.html#ThreadedHTTPServer">ThreadedHTTPServer</a>(<a href="SocketServer.html#ThreadingMixIn">SocketServer.ThreadingMixIn</a>, <a href="BaseHTTPServer.html#HTTPServer">BaseHTTPServer.HTTPServer</a>)
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="SocketServer.html#ThreadingMixIn">SocketServer.ThreadingMixIn</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="newlib.SmapHttp.html#ThreadedHTTPServer">ThreadedHTTPServer</a>(<a href="SocketServer.html#ThreadingMixIn">SocketServer.ThreadingMixIn</a>, <a href="BaseHTTPServer.html#HTTPServer">BaseHTTPServer.HTTPServer</a>)
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="exceptions.html#Exception">exceptions.Exception</a>(<a href="exceptions.html#BaseException">exceptions.BaseException</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="newlib.SmapHttp.html#SmapHttpException">SmapHttpException</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="SmapHandler">class <strong>SmapHandler</strong></a>(<a href="BaseHTTPServer.html#BaseHTTPRequestHandler">BaseHTTPServer.BaseHTTPRequestHandler</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="newlib.SmapHttp.html#SmapHandler">SmapHandler</a></dd>
<dd><a href="BaseHTTPServer.html#BaseHTTPRequestHandler">BaseHTTPServer.BaseHTTPRequestHandler</a></dd>
<dd><a href="SocketServer.html#StreamRequestHandler">SocketServer.StreamRequestHandler</a></dd>
<dd><a href="SocketServer.html#BaseRequestHandler">SocketServer.BaseRequestHandler</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="SmapHandler-do_DELETE"><strong>do_DELETE</strong></a>(self)</dt></dl>

<dl><dt><a name="SmapHandler-do_GET"><strong>do_GET</strong></a>(self)</dt></dl>

<dl><dt><a name="SmapHandler-do_POST"><strong>do_POST</strong></a>(self)</dt></dl>

<dl><dt><a name="SmapHandler-log_error"><strong>log_error</strong></a>(self, fmt, *args)</dt></dl>

<dl><dt><a name="SmapHandler-log_message"><strong>log_message</strong></a>(self, fmt, *args)</dt></dl>

<hr>
Methods inherited from <a href="BaseHTTPServer.html#BaseHTTPRequestHandler">BaseHTTPServer.BaseHTTPRequestHandler</a>:<br>
<dl><dt><a name="SmapHandler-address_string"><strong>address_string</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;client&nbsp;address&nbsp;formatted&nbsp;for&nbsp;logging.<br>
&nbsp;<br>
This&nbsp;version&nbsp;looks&nbsp;up&nbsp;the&nbsp;full&nbsp;hostname&nbsp;using&nbsp;gethostbyaddr(),<br>
and&nbsp;tries&nbsp;to&nbsp;find&nbsp;a&nbsp;name&nbsp;that&nbsp;contains&nbsp;at&nbsp;least&nbsp;one&nbsp;dot.</tt></dd></dl>

<dl><dt><a name="SmapHandler-date_time_string"><strong>date_time_string</strong></a>(self, timestamp<font color="#909090">=None</font>)</dt><dd><tt>Return&nbsp;the&nbsp;current&nbsp;date&nbsp;and&nbsp;time&nbsp;formatted&nbsp;for&nbsp;a&nbsp;message&nbsp;header.</tt></dd></dl>

<dl><dt><a name="SmapHandler-end_headers"><strong>end_headers</strong></a>(self)</dt><dd><tt>Send&nbsp;the&nbsp;blank&nbsp;line&nbsp;ending&nbsp;the&nbsp;MIME&nbsp;headers.</tt></dd></dl>

<dl><dt><a name="SmapHandler-handle"><strong>handle</strong></a>(self)</dt><dd><tt>Handle&nbsp;multiple&nbsp;requests&nbsp;if&nbsp;necessary.</tt></dd></dl>

<dl><dt><a name="SmapHandler-handle_one_request"><strong>handle_one_request</strong></a>(self)</dt><dd><tt>Handle&nbsp;a&nbsp;single&nbsp;HTTP&nbsp;request.<br>
&nbsp;<br>
You&nbsp;normally&nbsp;don't&nbsp;need&nbsp;to&nbsp;override&nbsp;this&nbsp;method;&nbsp;see&nbsp;the&nbsp;class<br>
__doc__&nbsp;string&nbsp;for&nbsp;information&nbsp;on&nbsp;how&nbsp;to&nbsp;handle&nbsp;specific&nbsp;HTTP<br>
commands&nbsp;such&nbsp;as&nbsp;GET&nbsp;and&nbsp;POST.</tt></dd></dl>

<dl><dt><a name="SmapHandler-log_date_time_string"><strong>log_date_time_string</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;current&nbsp;time&nbsp;formatted&nbsp;for&nbsp;logging.</tt></dd></dl>

<dl><dt><a name="SmapHandler-log_request"><strong>log_request</strong></a>(self, code<font color="#909090">='-'</font>, size<font color="#909090">='-'</font>)</dt><dd><tt>Log&nbsp;an&nbsp;accepted&nbsp;request.<br>
&nbsp;<br>
This&nbsp;is&nbsp;called&nbsp;by&nbsp;<a href="#SmapHandler-send_response">send_response</a>().</tt></dd></dl>

<dl><dt><a name="SmapHandler-parse_request"><strong>parse_request</strong></a>(self)</dt><dd><tt>Parse&nbsp;a&nbsp;request&nbsp;(internal).<br>
&nbsp;<br>
The&nbsp;request&nbsp;should&nbsp;be&nbsp;stored&nbsp;in&nbsp;self.<strong>raw_requestline</strong>;&nbsp;the&nbsp;results<br>
are&nbsp;in&nbsp;self.<strong>command</strong>,&nbsp;self.<strong>path</strong>,&nbsp;self.<strong>request_version</strong>&nbsp;and<br>
self.<strong>headers</strong>.<br>
&nbsp;<br>
Return&nbsp;True&nbsp;for&nbsp;success,&nbsp;False&nbsp;for&nbsp;failure;&nbsp;on&nbsp;failure,&nbsp;an<br>
error&nbsp;is&nbsp;sent&nbsp;back.</tt></dd></dl>

<dl><dt><a name="SmapHandler-send_error"><strong>send_error</strong></a>(self, code, message<font color="#909090">=None</font>)</dt><dd><tt>Send&nbsp;and&nbsp;log&nbsp;an&nbsp;error&nbsp;reply.<br>
&nbsp;<br>
Arguments&nbsp;are&nbsp;the&nbsp;error&nbsp;code,&nbsp;and&nbsp;a&nbsp;detailed&nbsp;message.<br>
The&nbsp;detailed&nbsp;message&nbsp;defaults&nbsp;to&nbsp;the&nbsp;short&nbsp;entry&nbsp;matching&nbsp;the<br>
response&nbsp;code.<br>
&nbsp;<br>
This&nbsp;sends&nbsp;an&nbsp;error&nbsp;response&nbsp;(so&nbsp;it&nbsp;must&nbsp;be&nbsp;called&nbsp;before&nbsp;any<br>
output&nbsp;has&nbsp;been&nbsp;generated),&nbsp;logs&nbsp;the&nbsp;error,&nbsp;and&nbsp;finally&nbsp;sends<br>
a&nbsp;piece&nbsp;of&nbsp;HTML&nbsp;explaining&nbsp;the&nbsp;error&nbsp;to&nbsp;the&nbsp;user.</tt></dd></dl>

<dl><dt><a name="SmapHandler-send_header"><strong>send_header</strong></a>(self, keyword, value)</dt><dd><tt>Send&nbsp;a&nbsp;MIME&nbsp;header.</tt></dd></dl>

<dl><dt><a name="SmapHandler-send_response"><strong>send_response</strong></a>(self, code, message<font color="#909090">=None</font>)</dt><dd><tt>Send&nbsp;the&nbsp;response&nbsp;header&nbsp;and&nbsp;log&nbsp;the&nbsp;response&nbsp;code.<br>
&nbsp;<br>
Also&nbsp;send&nbsp;two&nbsp;standard&nbsp;headers&nbsp;with&nbsp;the&nbsp;server&nbsp;software<br>
version&nbsp;and&nbsp;the&nbsp;current&nbsp;date.</tt></dd></dl>

<dl><dt><a name="SmapHandler-version_string"><strong>version_string</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;server&nbsp;software&nbsp;version&nbsp;string.</tt></dd></dl>

<hr>
Data and other attributes inherited from <a href="BaseHTTPServer.html#BaseHTTPRequestHandler">BaseHTTPServer.BaseHTTPRequestHandler</a>:<br>
<dl><dt><strong>MessageClass</strong> = &lt;class mimetools.Message at 0x18b1650&gt;</dl>

<dl><dt><strong>default_request_version</strong> = 'HTTP/0.9'</dl>

<dl><dt><strong>error_content_type</strong> = 'text/html'</dl>

<dl><dt><strong>error_message_format</strong> = '&lt;head&gt;<font color="#c040c0">\n</font>&lt;title&gt;Error response&lt;/title&gt;<font color="#c040c0">\n</font>&lt;/head&gt;<font color="#c040c0">\n</font>&lt;bo...ode explanation: %(code)s = %(explain)s.<font color="#c040c0">\n</font>&lt;/body&gt;<font color="#c040c0">\n</font>'</dl>

<dl><dt><strong>monthname</strong> = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']</dl>

<dl><dt><strong>protocol_version</strong> = 'HTTP/1.0'</dl>

<dl><dt><strong>responses</strong> = {100: ('Continue', 'Request received, please continue'), 101: ('Switching Protocols', 'Switching to new protocol; obey Upgrade header'), 200: ('OK', 'Request fulfilled, document follows'), 201: ('Created', 'Document created, URL follows'), 202: ('Accepted', 'Request accepted, processing continues off-line'), 203: ('Non-Authoritative Information', 'Request fulfilled from cache'), 204: ('No Content', 'Request fulfilled, nothing follows'), 205: ('Reset Content', 'Clear input form for further input.'), 206: ('Partial Content', 'Partial content follows.'), 300: ('Multiple Choices', 'Object has several resources -- see URI list'), ...}</dl>

<dl><dt><strong>server_version</strong> = 'BaseHTTP/0.3'</dl>

<dl><dt><strong>sys_version</strong> = 'Python/2.6.4'</dl>

<dl><dt><strong>weekdayname</strong> = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']</dl>

<hr>
Methods inherited from <a href="SocketServer.html#StreamRequestHandler">SocketServer.StreamRequestHandler</a>:<br>
<dl><dt><a name="SmapHandler-finish"><strong>finish</strong></a>(self)</dt></dl>

<dl><dt><a name="SmapHandler-setup"><strong>setup</strong></a>(self)</dt></dl>

<hr>
Data and other attributes inherited from <a href="SocketServer.html#StreamRequestHandler">SocketServer.StreamRequestHandler</a>:<br>
<dl><dt><strong>rbufsize</strong> = -1</dl>

<dl><dt><strong>wbufsize</strong> = 0</dl>

<hr>
Methods inherited from <a href="SocketServer.html#BaseRequestHandler">SocketServer.BaseRequestHandler</a>:<br>
<dl><dt><a name="SmapHandler-__init__"><strong>__init__</strong></a>(self, request, client_address, server)</dt></dl>

</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="SmapHttpException">class <strong>SmapHttpException</strong></a>(<a href="exceptions.html#Exception">exceptions.Exception</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="newlib.SmapHttp.html#SmapHttpException">SmapHttpException</a></dd>
<dd><a href="exceptions.html#Exception">exceptions.Exception</a></dd>
<dd><a href="exceptions.html#BaseException">exceptions.BaseException</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="SmapHttpException-__init__"><strong>__init__</strong></a>(self, code)</dt></dl>

<dl><dt><a name="SmapHttpException-__str__"><strong>__str__</strong></a>(self)</dt></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<hr>
Data and other attributes inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br>
<dl><dt><strong>__new__</strong> = &lt;built-in method __new__ of type object at 0x7f551aac0880&gt;<dd><tt>T.<a href="#SmapHttpException-__new__">__new__</a>(S,&nbsp;...)&nbsp;-&gt;&nbsp;a&nbsp;new&nbsp;object&nbsp;with&nbsp;type&nbsp;S,&nbsp;a&nbsp;subtype&nbsp;of&nbsp;T</tt></dl>

<hr>
Methods inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br>
<dl><dt><a name="SmapHttpException-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#SmapHttpException-__delattr__">__delattr__</a>('name')&nbsp;&lt;==&gt;&nbsp;del&nbsp;x.name</tt></dd></dl>

<dl><dt><a name="SmapHttpException-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#SmapHttpException-__getattribute__">__getattribute__</a>('name')&nbsp;&lt;==&gt;&nbsp;x.name</tt></dd></dl>

<dl><dt><a name="SmapHttpException-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#SmapHttpException-__getitem__">__getitem__</a>(y)&nbsp;&lt;==&gt;&nbsp;x[y]</tt></dd></dl>

<dl><dt><a name="SmapHttpException-__getslice__"><strong>__getslice__</strong></a>(...)</dt><dd><tt>x.<a href="#SmapHttpException-__getslice__">__getslice__</a>(i,&nbsp;j)&nbsp;&lt;==&gt;&nbsp;x[i:j]<br>
&nbsp;<br>
Use&nbsp;of&nbsp;negative&nbsp;indices&nbsp;is&nbsp;not&nbsp;supported.</tt></dd></dl>

<dl><dt><a name="SmapHttpException-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl>

<dl><dt><a name="SmapHttpException-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#SmapHttpException-__repr__">__repr__</a>()&nbsp;&lt;==&gt;&nbsp;repr(x)</tt></dd></dl>

<dl><dt><a name="SmapHttpException-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#SmapHttpException-__setattr__">__setattr__</a>('name',&nbsp;value)&nbsp;&lt;==&gt;&nbsp;x.name&nbsp;=&nbsp;value</tt></dd></dl>

<dl><dt><a name="SmapHttpException-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>

<dl><dt><a name="SmapHttpException-__unicode__"><strong>__unicode__</strong></a>(...)</dt></dl>

<hr>
Data descriptors inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
</dl>
<dl><dt><strong>args</strong></dt>
</dl>
<dl><dt><strong>message</strong></dt>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="ThreadedHTTPServer">class <strong>ThreadedHTTPServer</strong></a>(<a href="SocketServer.html#ThreadingMixIn">SocketServer.ThreadingMixIn</a>, <a href="BaseHTTPServer.html#HTTPServer">BaseHTTPServer.HTTPServer</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Handle&nbsp;requests&nbsp;in&nbsp;a&nbsp;separate&nbsp;thread.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="newlib.SmapHttp.html#ThreadedHTTPServer">ThreadedHTTPServer</a></dd>
<dd><a href="SocketServer.html#ThreadingMixIn">SocketServer.ThreadingMixIn</a></dd>
<dd><a href="BaseHTTPServer.html#HTTPServer">BaseHTTPServer.HTTPServer</a></dd>
<dd><a href="SocketServer.html#TCPServer">SocketServer.TCPServer</a></dd>
<dd><a href="SocketServer.html#BaseServer">SocketServer.BaseServer</a></dd>
</dl>
<hr>
Methods inherited from <a href="SocketServer.html#ThreadingMixIn">SocketServer.ThreadingMixIn</a>:<br>
<dl><dt><a name="ThreadedHTTPServer-process_request"><strong>process_request</strong></a>(self, request, client_address)</dt><dd><tt>Start&nbsp;a&nbsp;new&nbsp;thread&nbsp;to&nbsp;process&nbsp;the&nbsp;request.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-process_request_thread"><strong>process_request_thread</strong></a>(self, request, client_address)</dt><dd><tt>Same&nbsp;as&nbsp;in&nbsp;BaseServer&nbsp;but&nbsp;as&nbsp;a&nbsp;thread.<br>
&nbsp;<br>
In&nbsp;addition,&nbsp;exception&nbsp;handling&nbsp;is&nbsp;done&nbsp;here.</tt></dd></dl>

<hr>
Data and other attributes inherited from <a href="SocketServer.html#ThreadingMixIn">SocketServer.ThreadingMixIn</a>:<br>
<dl><dt><strong>daemon_threads</strong> = False</dl>

<hr>
Methods inherited from <a href="BaseHTTPServer.html#HTTPServer">BaseHTTPServer.HTTPServer</a>:<br>
<dl><dt><a name="ThreadedHTTPServer-server_bind"><strong>server_bind</strong></a>(self)</dt><dd><tt>Override&nbsp;server_bind&nbsp;to&nbsp;store&nbsp;the&nbsp;server&nbsp;name.</tt></dd></dl>

<hr>
Data and other attributes inherited from <a href="BaseHTTPServer.html#HTTPServer">BaseHTTPServer.HTTPServer</a>:<br>
<dl><dt><strong>allow_reuse_address</strong> = 1</dl>

<hr>
Methods inherited from <a href="SocketServer.html#TCPServer">SocketServer.TCPServer</a>:<br>
<dl><dt><a name="ThreadedHTTPServer-__init__"><strong>__init__</strong></a>(self, server_address, RequestHandlerClass, bind_and_activate<font color="#909090">=True</font>)</dt><dd><tt>Constructor.&nbsp;&nbsp;May&nbsp;be&nbsp;extended,&nbsp;do&nbsp;not&nbsp;override.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-close_request"><strong>close_request</strong></a>(self, request)</dt><dd><tt>Called&nbsp;to&nbsp;clean&nbsp;up&nbsp;an&nbsp;individual&nbsp;request.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-fileno"><strong>fileno</strong></a>(self)</dt><dd><tt>Return&nbsp;socket&nbsp;file&nbsp;number.<br>
&nbsp;<br>
Interface&nbsp;required&nbsp;by&nbsp;select().</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-get_request"><strong>get_request</strong></a>(self)</dt><dd><tt>Get&nbsp;the&nbsp;request&nbsp;and&nbsp;client&nbsp;address&nbsp;from&nbsp;the&nbsp;socket.<br>
&nbsp;<br>
May&nbsp;be&nbsp;overridden.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-server_activate"><strong>server_activate</strong></a>(self)</dt><dd><tt>Called&nbsp;by&nbsp;constructor&nbsp;to&nbsp;activate&nbsp;the&nbsp;server.<br>
&nbsp;<br>
May&nbsp;be&nbsp;overridden.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-server_close"><strong>server_close</strong></a>(self)</dt><dd><tt>Called&nbsp;to&nbsp;clean-up&nbsp;the&nbsp;server.<br>
&nbsp;<br>
May&nbsp;be&nbsp;overridden.</tt></dd></dl>

<hr>
Data and other attributes inherited from <a href="SocketServer.html#TCPServer">SocketServer.TCPServer</a>:<br>
<dl><dt><strong>address_family</strong> = 2</dl>

<dl><dt><strong>request_queue_size</strong> = 5</dl>

<dl><dt><strong>socket_type</strong> = 1</dl>

<hr>
Methods inherited from <a href="SocketServer.html#BaseServer">SocketServer.BaseServer</a>:<br>
<dl><dt><a name="ThreadedHTTPServer-finish_request"><strong>finish_request</strong></a>(self, request, client_address)</dt><dd><tt>Finish&nbsp;one&nbsp;request&nbsp;by&nbsp;instantiating&nbsp;RequestHandlerClass.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-handle_error"><strong>handle_error</strong></a>(self, request, client_address)</dt><dd><tt>Handle&nbsp;an&nbsp;error&nbsp;gracefully.&nbsp;&nbsp;May&nbsp;be&nbsp;overridden.<br>
&nbsp;<br>
The&nbsp;default&nbsp;is&nbsp;to&nbsp;print&nbsp;a&nbsp;traceback&nbsp;and&nbsp;continue.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-handle_request"><strong>handle_request</strong></a>(self)</dt><dd><tt>Handle&nbsp;one&nbsp;request,&nbsp;possibly&nbsp;blocking.<br>
&nbsp;<br>
Respects&nbsp;self.<strong>timeout</strong>.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-handle_timeout"><strong>handle_timeout</strong></a>(self)</dt><dd><tt>Called&nbsp;if&nbsp;no&nbsp;new&nbsp;request&nbsp;arrives&nbsp;within&nbsp;self.<strong>timeout</strong>.<br>
&nbsp;<br>
Overridden&nbsp;by&nbsp;ForkingMixIn.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-serve_forever"><strong>serve_forever</strong></a>(self, poll_interval<font color="#909090">=0.5</font>)</dt><dd><tt>Handle&nbsp;one&nbsp;request&nbsp;at&nbsp;a&nbsp;time&nbsp;until&nbsp;shutdown.<br>
&nbsp;<br>
Polls&nbsp;for&nbsp;shutdown&nbsp;every&nbsp;poll_interval&nbsp;seconds.&nbsp;Ignores<br>
self.<strong>timeout</strong>.&nbsp;If&nbsp;you&nbsp;need&nbsp;to&nbsp;do&nbsp;periodic&nbsp;tasks,&nbsp;do&nbsp;them&nbsp;in<br>
another&nbsp;thread.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-shutdown"><strong>shutdown</strong></a>(self)</dt><dd><tt>Stops&nbsp;the&nbsp;serve_forever&nbsp;loop.<br>
&nbsp;<br>
Blocks&nbsp;until&nbsp;the&nbsp;loop&nbsp;has&nbsp;finished.&nbsp;This&nbsp;must&nbsp;be&nbsp;called&nbsp;while<br>
<a href="#ThreadedHTTPServer-serve_forever">serve_forever</a>()&nbsp;is&nbsp;running&nbsp;in&nbsp;another&nbsp;thread,&nbsp;or&nbsp;it&nbsp;will<br>
deadlock.</tt></dd></dl>

<dl><dt><a name="ThreadedHTTPServer-verify_request"><strong>verify_request</strong></a>(self, request, client_address)</dt><dd><tt>Verify&nbsp;the&nbsp;request.&nbsp;&nbsp;May&nbsp;be&nbsp;overridden.<br>
&nbsp;<br>
Return&nbsp;True&nbsp;if&nbsp;we&nbsp;should&nbsp;proceed&nbsp;with&nbsp;this&nbsp;request.</tt></dd></dl>

<hr>
Data and other attributes inherited from <a href="SocketServer.html#BaseServer">SocketServer.BaseServer</a>:<br>
<dl><dt><strong>timeout</strong> = None</dl>

</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-lock"><strong>lock</strong></a>()</dt></dl>
 <dl><dt><a name="-recursive_get"><strong>recursive_get</strong></a>(resource, root)</dt><dd><tt>Get&nbsp;an&nbsp;object&nbsp;recursively&nbsp;based&nbsp;on&nbsp;a&nbsp;resource&nbsp;request.<br>
Supports&nbsp;the&nbsp;"star"&nbsp;(*)&nbsp;syntax&nbsp;for&nbsp;requesting&nbsp;a&nbsp;collection<br>
&nbsp;<br>
@resource&nbsp;a&nbsp;resource&nbsp;name,&nbsp;as&nbsp;in&nbsp;one&nbsp;returned&nbsp;by&nbsp;urlparse.urlsplit<br>
@root&nbsp;a&nbsp;dict&nbsp;to&nbsp;fetch&nbsp;the&nbsp;resource&nbsp;against.&nbsp;&nbsp;The&nbsp;objects&nbsp;at&nbsp;the&nbsp;leaves<br>
&nbsp;&nbsp;&nbsp;&nbsp;must&nbsp;have&nbsp;an&nbsp;http_get&nbsp;method,&nbsp;which&nbsp;will&nbsp;be&nbsp;called&nbsp;to&nbsp;generate&nbsp;the&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;json&nbsp;response.<br>
&nbsp;<br>
throws:&nbsp;<a href="#SmapHttpException">SmapHttpException</a>&nbsp;if&nbsp;there&nbsp;is&nbsp;a&nbsp;server-type&nbsp;error;&nbsp;includes&nbsp;an&nbsp;http&nbsp;code<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="exceptions.html#Exception">Exception</a>:&nbsp;if&nbsp;the&nbsp;dict&nbsp;object&nbsp;doesn't&nbsp;have&nbsp;a&nbsp;proper&nbsp;object&nbsp;at&nbsp;a&nbsp;leaf</tt></dd></dl>
 <dl><dt><a name="-recursive_method"><strong>recursive_method</strong></a>(method, resource, root, *extra)</dt></dl>
 <dl><dt><a name="-release"><strong>release</strong></a>()</dt></dl>
 <dl><dt><a name="-smap_server_init"><strong>smap_server_init</strong></a>()</dt></dl>
 <dl><dt><a name="-start_instances"><strong>start_instances</strong></a>(place)</dt></dl>
 <dl><dt><a name="-start_server"><strong>start_server</strong></a>(root, background<font color="#909090">=False</font>, port<font color="#909090">=8080</font>)</dt><dd><tt>Start&nbsp;a&nbsp;sMAP&nbsp;http&nbsp;server<br>
&nbsp;<br>
@root&nbsp;an&nbsp;object&nbsp;representing&nbsp;the&nbsp;web&nbsp;hierarchy&nbsp;to&nbsp;server.&nbsp;&nbsp;It&nbsp;may<br>
either&nbsp;be&nbsp;a&nbsp;SmapInstance&nbsp;object,&nbsp;or&nbsp;an&nbsp;arbitrarily-deep&nbsp;set&nbsp;of&nbsp;dicts,<br>
with&nbsp;all&nbsp;leaf&nbsp;values&nbsp;being&nbsp;SmapInstances.&nbsp;&nbsp;The&nbsp;server&nbsp;will&nbsp;present<br>
this&nbsp;hierarchy&nbsp;to&nbsp;the&nbsp;work&nbsp;using&nbsp;HTTP.<br>
@background&nbsp;if&nbsp;true,&nbsp;fork&nbsp;a&nbsp;thread&nbsp;for&nbsp;the&nbsp;server.&nbsp;&nbsp;Otherwise,&nbsp;this<br>
function&nbsp;never&nbsp;returns<br>
@port&nbsp;local&nbsp;port&nbsp;to&nbsp;run&nbsp;on</tt></dd></dl>
</td></tr></table>
</body></html>